<?php

class FunctionsComponent extends Object {
    
	
	function checkstatus($runid, $statusid) {
        $result = mysql_query("SELECT COUNT(*) AS count FROM `runshasstatusruns` WHERE `run_id` = '$runid' AND `status_id` = '$statusid'");    
    	$count = mysql_fetch_object($result)->count;
    	return $count;
	}
	
	
	function getstatusdate($runid,$statusid) {
		$result = mysql_query("SELECT date FROM `runshasstatusruns` WHERE `run_id` = '$runid' AND `status_id` = '$statusid'");
		$date = mysql_fetch_object($result)->date;
		return $date;	
	}
	
	
	function checkdtv($runid){
		$result = mysql_query("SELECT COUNT(*) count FROM runs r, projects p, projectshasmacservicetypes phm, macservicetypes mst WHERE r.project_id = p.id AND p.id = phm.project_id AND phm.macservicetype_id = mst.id AND mst.service = 'DTV' AND r.id = '$runid'");
		$count = mysql_fetch_object($result)->count;
		return $count;	
	}
	
	
	function checkdtv2($pid){
		$result = mysql_query("SELECT COUNT(*) count FROM projects p, projectshasmacservicetypes phm, macservicetypes mst WHERE p.id = phm.project_id AND phm.macservicetype_id = mst.id AND mst.service = 'DTV' AND p.id = '$pid'");
		$count = mysql_fetch_object($result)->count;
		return $count;
	}
	
	
	function getBatchStartDate($runid){
		$result = mysql_query("SELECT batchstarttime FROM `runs` WHERE `id` = '$runid'");
		return $batchstarttime = mysql_fetch_object($result)->batchstarttime;	
	}
	
}

?>
